<div class="container-fluid">

	<!-- affichage des messages Flash-->
  	<div class="row-fluid">
		<div class="span12">
			<?php echo $this->Session_gpp->flash();?>
		</div>
	</div>

	<!-- Titre de la page-->
	<div class="row-fluid">
		<div class="span12">
			<legend><?php echo __('Creation d\'une Nouvelle Application'); ?></legend>
		</div>
	</div>

	<!-- Barre des boutons-->
	<div class="row-fluid">
		<div class="span12">
			<div class="navbar"/>
				<div class="navbar-inner_gpp">
					<div class="container-fluid">
						<div class="nav-collapse">
							<div class="row-fluid">
								<div class="span2">
									<a href="#" class="btn btn-success btn-small" onclick="document.getElementById('ApplicationAddForm').submit();"><i class="icon-ok icon-white"></i><?php echo __(' Enregistrer')?></a>
			        			</div>
								<div class="span2">	
									<a href="./index" class="btn btn-inverse btn-small"><i class="icon-remove icon-white"></i><?php echo __(' Annuler')?></a>
						  		</div>
								<div class="span2">	
									<a href="#" onclick="TesterConnexion()" class="btn btn-inverse btn-small"><i class="icon-signal icon-white"></i><?php echo __(' Tester la connexion')?></a>
						  		</div>
								<div class="span6">	
								</div>
						  	</div>
										
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<!-- div de saisie des informations-->
	<?php echo $this->Form->create('Application');?>
		<div class="row-fluid">
	  		<div class="span4">
				<div class="applications form">
					<fieldset>
					<?php
						echo $this->Form->input('name');
						echo $this->Form->input('description');
					?>
						<div class="input text">
							<label for="ApplicationHebergement">Hebergement</label>
							<select name="data[Application][hebergement]" id="ApplicationHebergement">
								<option value="0" selected><?php echo __('Bdd local')?></option>';
								<option value="1" ><?php echo __('Bdd distante')?></option>';
							</select>
						</div>
					</fieldset>
				</div>
			</div>
	  		<div class="span8">
					<fieldset>
						<h4> Info Connexion Bdd Distante</h4>
						<div class="input text">
							<label for="ApplicationPgdatabase_id">Database</label>
							<select name="data[Application][pgdatabase_id]" id="ApplicationPgdatabase_id">
								<?php foreach ($pgdatabases as $key => $value) {
									echo '<option value="'.$key.'">'.$value.'</option>';
								}?>
							</select>
						</div>
					<?php
						echo $this->Form->input('host');
						echo $this->Form->input('port');
						echo $this->Form->input('sid');
						echo $this->Form->input('login');
						echo $this->Form->input('mdp');
					?>
					</fieldset>
			</div>
		</div>
	<?php echo $this->Form->end();?>
</div>

<script type="text/javascript">
	
	function TesterConnexion (){
		var ApplicationPgdatabase=document.getElementById('ApplicationPgdatabase_id').value;
		var ApplicationHost=document.getElementById('ApplicationHost').value;
		var ApplicationPort=document.getElementById('ApplicationPort').value;
		var ApplicationSid=document.getElementById('ApplicationSid').value;
		var ApplicationLogin=document.getElementById('ApplicationLogin').value;
		var ApplicationMdp=document.getElementById('ApplicationMdp').value;

		var urlTester="./TesterConnexion_ajax/"+ApplicationPgdatabase+"/"+ApplicationHost+"/"+ApplicationPort+"/"+ApplicationSid+"/"+ApplicationLogin+"/"+ApplicationMdp;

		//alert(urlTester);

		$.ajax({
		  	type: "GET",
		  	url: urlTester,
		   	error:function(msg){
		     	alert( "Error !: " + msg );
		   	},
		   	success:function(data){
		   		alert(data);
			}
		});
	}

</script>

